#!/bin/bash
# 启动MCP服务器的脚本

# 进入脚本所在目录
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" || exit
cur_dir=$(pwd)

# 设置PYTHONPATH，确保能找到mcp模块
export PYTHONPATH="$(pwd):$PYTHONPATH"

blue()  { echo -e "\033[34m$1\033[0m"; }
red()   { echo -e "\033[31m$1\033[0m"; }

# 检查是否在虚拟环境中
if [ -z "$VIRTUAL_ENV" ]; then
    red "请先激活虚拟环境."
    exit 1
fi

# 启动Milvus服务
echo "启动Milvus服务..."
sh milvus_server/start_milvus.sh
if [ $? -ne 0 ]; then
    red "启动Milvus服务失败，退出脚本"
    exit 1
fi
cd $cur_dir
echo ""

# 启动MCP服务器
echo "启动MCP服务器..."
sh mcp/start_mcp.sh
if [ $? -ne 0 ]; then
    red "启动MCP服务器失败，退出脚本"
    exit 1
fi
cd $cur_dir
